<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>对象拓展运算符</title>
</head>
<body>
<script>
    <!-- 拓展运算符（...）用于取出参数对象所有可遍历属性然后拷贝到当前对象。-->
    let user = {name:"张三", age: 18};
    //对象复制
    let  zhangsan={...user}
    console.log(zhangsan);

    //对象的属性合并
    let hobby = "music";
    let  zhangsan2 = {...user,hobby,address:"郑州"};
    console.log(zhangsan2);

    // ...可以和解构数组组合属性
    let arr = [1,2,3,4,5];
    let [x,y,...z]=arr;
    console.log(x,y,z); //x=1, y=2, z=[3, 4, 5];
</script>
</body>
</html>